<template>
    <dl class="birth">
        <dt>
            <p>
                <span class="f26">姓名：{{items.name}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <span class="f26">性别：{{items.sex}}</span>
            </p>
            <p>
                <span class="f26">(公历)</span>
                <span class="f26">生日：{{items.birth}}&nbsp;&nbsp;&nbsp;</span>
                <span class="f26">时辰：{{items.birthTime}}</span>
            </p>
            <p>
                <span class="f26">出生地：{{items.areaName}}</span>
            </p>
        </dt>
        <dd>
            <div class="inp" @change="baziSetDefault(items.id)">
                <input type="radio" name="moren" :checked="items.asdefault == 1 ? true : false">
                <span class="f26">设为常用</span>
            </div>
            <div class="btn">
                <button class="f26" @click="redact(items.id)">编辑</button>
                <button class="f26" @click="bazidelete(items.id)">删除</button>
            </div>
        </dd>
    </dl>
</template>

<script>
    import Bus from '../bus/bus.js'
    export default {
        name: 'birth',
        props: {
            items: Object,
            shan: Function
        },
        data() {
            return {

            }
        },
        methods: {
            bazidelete(itemId) {
                Bus.$emit('shanchu', {
                    baId: itemId,
                    isShow: true
                })
            },
            baziSetDefault(ids) {
                let params = {
                    userId: this.$store.state.userId,
                    id: ids 
                }
                this.$http.fetchGet('baziSetDefault', params).then(res => {
                    if(res.code == 200) {
                        this.$vux.toast.text(res.msg)
                        this.shan()
                    } else {
                        this.$vux.toast.text(res.msg)
                    }
                }, err => {
                    console.log(err)
                })
            },
            redact(id) {
                this.$router.push({//你需要接受路由的参数再跳转
                    path: '/horoscope',
                    query: {
                        id: id
                    }
                })
            }
        },
        mounted() {

        }
    }
</script>

<style lang="less" scoped>
    .birth{
        width: 100%;
        background: #fff;
        .mb(20);
        .pl(20);
        .pr(20);
        box-sizing: border-box;
        dt{
            border-bottom: 1px solid #f2f2f2;
            .pt(10);
            .pb(10);
            box-sizing: border-box;
            p{
                .lh(50);
                span{
                    .mr(10);
                }
            }
        }
        dd{
            .h(88);
            line-height: 88px;
            .lh(88);
            display: flex;
            position: relative;
            .btn{
                position: absolute;
                right: 10px;
                button{
                    border: none;
                    background: #fff;
                    color: #666;
                }
            }
        }
    }
</style>
